/**
 * gislin 2017年7月17日
 */
package com.btcode.orm.filter;

import com.btcode.db.wherefilter.IWhereFilter;
import com.btcode.db.wherefilter.WhereFilterMulit;
import com.btcode.db.wherefilter.WhereFilterSingle;
import java.util.ArrayList;
import java.util.List;

/**
 * @author gislin 2017年7月17日
 */
public class FilterGroup implements IFilter {

    List<FilterSingle> filters = new ArrayList<FilterSingle>();

    public void addFilter(FilterSingle filter) {
        filters.add(filter);
    }

    @Override
    public IWhereFilter getWhereFilter() {

        if (filters == null || filters.size() == 0) {
            return null;
        }

        WhereFilterMulit whereFilter = new WhereFilterMulit();
        for (FilterSingle filter : filters) {
            whereFilter.addOperation((WhereFilterSingle) filter.getWhereFilter());
        }

        return whereFilter;

    }

}
